import { resolve } from 'path';
import ScriptSetup from 'unplugin-vue2-script-setup/vite';
import { defineConfig } from 'vite';
import { createVuePlugin as vue2 } from 'vite-plugin-vue2';
import { createSvgPlugin } from 'vite-plugin-vue2-svg';

export default defineConfig({
    base: './',
    resolve: {
        alias: [
            {
                find: '@',
                replacement: resolve(__dirname, 'example'),
            },
            {
                find: 'vue',
                replacement: resolve(__dirname, 'node_modules/vue2/dist/vue.runtime.esm.js'),
            },
            {
                find: 'vue-demi',
                replacement: resolve(__dirname, 'node_modules/vue-demi/lib/v2/index.mjs'),
            },
        ],
        extensions: ['.ts', '.tsx', '.vue'],
    },
    server: {
        host: '0.0.0.0',
        port: 8080,
    },
    build: {
        outDir: resolve(__dirname, 'dist/example'),
        // 开启源映射
        sourcemap: true
    },
    plugins: [vue2(), createSvgPlugin(), ScriptSetup({})],
});    